/**
 * 剪刀类
 */
class CutAbout extends egret.DisplayObjectContainer {
    /** 加载剪刀 */
    private cut_png: egret.Bitmap = Main.createBitmapByName("cut1_png");
    /** 剪刀动画定时器 */
    private timer: egret.Timer = new egret.Timer(1000 / 3);

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }
    private init() {
        this.addChild(this.cut_png);
        /** 设置剪刀属性 */
        this.cutSetting();

        Main.dragGetPatn(this.cut_png, this, {
            startFun: this.startDragCut,
            moveFun: this.moveDragCut
        });
        Main.anchorCenter(this.cut_png);
        Main.itemAniamtion(this.cut_png);
    }
    /** 设置剪刀属性 */
    private cutSetting() {
        this.cut_png.scaleX = .5 * .2;
        this.cut_png.scaleY = .5 * .2;
        this.cut_png.rotation = 45;
        this.cut_png.x = 462;
        this.cut_png.y = 384;
    }
    /** 剪刀执行动画 */
    private animation() {
        let num = 1;
        this.timer.addEventListener(egret.TimerEvent.TIMER, () => {
            num++;
            if (num > 3) num = 1;
            this.cut_png.texture = RES.getRes(`cut${num}_png`);
        }, this);
        this.timer.start();
    }
    /** 开始拖动剪刀 */
    private startDragCut(target, container) {
        console.log("触发开始拖动附加方法");
        
        egret.Tween.removeTweens(target);
        // container.animation();

        container.dispatchEvent(new egret.Event("move"));
    }
    /** 拖动剪刀中 */
    private moveDragCut(target, container) {
        if (target.hitTestPoint(600, 410)) {
            console.log("碰到了");

            container.dispatchEvent(new egret.Event("hit"));
        }
    }
}